C	    CALL TALLY(A,S,TOTAL,AVER,SD,VMIN,VMAX,NO,NV,IER)
C
C	 DESCRIPTION OF PARAMETERS
C	    A	  - OBSERVATION MATRIX, NO BY NV
C	    S	  - INPUT VECTOR INDICATING SUBSET OF A. ONLY THOSE
C		    OBSERVATIONS WITH A NON-ZERO S(J) ARE CONSIDERED.
C		    VECTOR LENGTH IS NO.
C	    TOTAL - OUTPUT VECTOR OF TOTALS OF EACH VARIABLE. VECTOR
C		    LENGTH IS NV.
C	    AVER  - OUTPUT VECTOR OF AVERAGES OF EACH VARIABLE. VECTOR
C		    LENGTH IS NV.
C	    SD	  - OUTPUT VECTOR OF STANDARD DEVIATIONS OF EACH
C		    VARIABLE. VECTOR LENGTH IS NV.
C	    VMIN  - OUTPUT VECTOR OF MINIMA OF EACH VARIABLE. VECTOR
C		    LENGTH IS NV.
C	    VMAX  - OUTPUT VECTOR OF MAXIMA OF EACH VARIABLE. VECTOR
C		    LENGTH IS NV.
C	    NO	  - NUMBER OF OBSERVATIONS
C	    NV	  - NUMBER OF VARIABLES FOR EACH OBSERVATION
C	    IER   - ZERO, IF NO ERROR.
C		  - 1, IF S IS NULL.  VMIN=-1.E75, VMAX=SD=AVER=1.E75.
C		  - 2, IF S HAS ONLY ONE NON-ZERO ELEMENT. VMIN=VMAX.
C		    SD=0.0
C
C	 REMARKS
C	    NONE
C
C	 SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C	    NONE
C
C	 METHOD
C	    ALL OBSERVATIONS CORRESPONDING TO A NON-ZERO ELEMENT IN S
C	    VECTOR ARE ANALYZED FOR EACH VARIABLE IN MATRIX A.
C	    TOTALS ARE ACCUMULATED AND MINIMUM AND MAXIMUM VALUES ARE
C	    FOUND. FOLLOWING THIS, MEANS AND STANDARD DEVIATIONS ARE
C	    CALCULATED.  THE DIVISOR FOR STANDARD DEVIATION IS ONE LESS
C	    THAN THE NUMBER OF OBSERVATIONS USED.
C
C     ..................................................................
C
      SUBROUTINE TALLY(A,S,TOTAL,AVER,SD,VMIN,VMAX,NO,NV)
      DIMENSION A(1),S(1),TOTAL(1),AVER(1),SD(1),VMIN(1),VMAX(1)
C
C	 CLEAR OUTPUT VECTORS AND INITIALIZE VMIN,VMAX
C
      IER=0
      DO 1 K=1,NV
      TOTAL(K)=0.0
      AVER(K)=1.0E38
      SD(K)=1.0E38
      VMIN(K)=-1.0E38
    1 VMAX(K)=1.0E38
C
C        TEST SUBSET VECTOR
C
      SCNT=0.0
      DO 7 J=1,NO
      IJ=J-NO
      IF(S(J)) 2,7,2
    2 SCNT=SCNT+1.0
C
C        CALCULATE TOTAL, MINIMA, MAXIMA
C
      DO 6 I=1,NV
      IJ=IJ+NO
      TOTAL(I)=TOTAL(I)+A(IJ)
      IF(A(IJ)-VMIN(I)) 3,4,4
    3 VMIN(I)=A(IJ)
    4 IF(A(IJ)-VMAX(I)) 6,6,5
    5 VMAX(I)=A(IJ)
    6 SD(I)=SD(I)+A(IJ)*A(IJ)
    7 CONTINUE
C
C        CALCULATE MEANS AND STANDARD DEVIATIONS
C
      IF (SCNT)8,8,9
    8 IER=1
      GO TO 15
    9 DO 10 I=1,NV
   10 AVER(I)=TOTAL(I)/SCNT
      IF (SCNT-1.0) 13,11,13
   11 IER=2
      DO 12 I=1,NV
   12 SD(I)=0.0
      GO TO 15
   13 DO 14 I=1,NV
   14 SD(I)=SQRT(ABS((SD(I)-TOTAL(I)*TOTAL(I)/SCNT)/(SCNT-1.0)))
   15 RETURN
      END
 IER=1
      GO TO 15
    9 DO 10 I=1,NV
   10 AVER(I)=TOTAL(I)/SCNT
      